home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-11 / vs_804.zip / MAINTSRC.EXE / GENINC.PRG < prev    next >
Text File  |  1991-10-25  |  6KB  |  209 lines

  1. * Filename......: GenInc.Prg
  2. *
  3. * Author........: Vernon E. Six, Jr.
  4. *
  5. * Last Update...: Fri  10-25-1991  10:57:39
  6. *
  7. * Notice........: Copyright (c) 1991 by Vernon E. Six, Jr.
  8. *                 All Rights Reserved World Wide
  9. *
  10. * Dialect.......: Clipper v5.0x
  11.  
  12. #include "INKEY.CH"
  13. #include "SETCURS.CH"
  14. #include "VERNSIX.CH"
  15.  
  16. FUNCTION GENINC
  17. *****
  18. * Generates individual CH files for each DATABASE
  19. *****                                            
  20. LOCAL n_Prior
  21. LOCAL c_Name
  22. LOCAL n_Handle
  23. LOCAL c_DbfPic
  24. LOCAL c_Picture
  25. LOCAL c_DefName
  26. LOCAL c_DbfDef
  27. LOCAL c_Default
  28. LOCAL c_PicName
  29.             
  30. VS_GrabScr()
  31.  
  32.    VS_TxtColr()
  33.    CLEAR SCREEN
  34.  
  35.    _DICTHDR->( dbGoTop() )
  36.  
  37.    DO WHILE .NOT. _DICTHDR->(EOF())
  38.  
  39.       OUTSTD(_DICTHDR->DBF_NAME+" ... "+_DICTHDR->DESC+CHR(13)+CHR(10))
  40.  
  41.       n_Handle := FCREATE(ALLTRIM(_DICTHDR->DBF_NAME)+".CH",0)
  42.  
  43.       VS_WriteLn( n_Handle )
  44.  
  45.       *══════════════════════════════════════════════════════════*
  46.  
  47.       VS_WriteLn( "* Filename......: "+ALLTRIM(_DICTHDR->DBF_NAME)+".CH"       )
  48.       VS_WriteLn( "*"                                                          )
  49.       VS_WriteLn( "* Author........: Vernon E. Six, Jr."                       )
  50.       VS_WriteLn( "*"                                                          )
  51.       VS_WriteLn( "* Last Update...: "+DTOC(DATE())+"  "+TIME()                )
  52.       VS_WriteLn( "*"                                                          )
  53.       VS_WriteLn( "* Notice........: Copyright (c) 1991 by Vernon E. Six, Jr." )
  54.       VS_WriteLn( "*                 All Rights Reserved World Wide"           )
  55.       VS_WriteLn( "*"                                                          )
  56.       VS_WriteLn( "* Purpose.......: Data Dictionary DEFINEs for "+;
  57.                                      ALLTRIM(_DICTHDR->DBF_NAME)+".DBF"        )
  58.  
  59.       *══════════════════════════════════════════════════════════*
  60.       
  61.       VS_WriteLn( "" )
  62.       VS_WriteLn( "" )
  63.  
  64.  
  65.       _DICTFLD->(DBSEEK(_DICTHDR->DBF_NAME))
  66.  
  67.       DO WHILE .NOT. _DICTFLD->(EOF())
  68.  
  69.          IF _DICTFLD->DBF_NAME <> _DICTHDR->DBF_NAME
  70.             EXIT
  71.          ENDIF
  72.  
  73.          c_DefName = "_DEF_"+ALLTRIM(_DICTFLD->DBF_NAME)  + ;
  74.                      "_"+ALLTRIM(_DICTFLD->FIELD_NAME)
  75.  
  76.          c_DbfDef  = ALLTRIM(_DICTFLD->DEFAULT)
  77.  
  78.  
  79.          *****
  80.          * What type of data are we working with?
  81.          *****
  82.          DO CASE
  83.  
  84.             CASE _DICTFLD->FIELD_TYPE = "C"
  85.  
  86.                IF EMPTY(c_DbfDef)
  87.                   c_Default = "SPACE("+ALLTRIM(STR(_DICTFLD->FIELD_LEN))+")"
  88.                 ELSE
  89.                   c_Default = c_DbfDef
  90.                ENDIF
  91.  
  92.  
  93.             CASE _DICTFLD->FIELD_TYPE = "N"
  94.                IF EMPTY(c_DbfDef)
  95.                   c_Default = "0"
  96.                 ELSE
  97.                   c_Default = c_DbfDef
  98.                ENDIF
  99.  
  100.  
  101.             CASE _DICTFLD->FIELD_TYPE = "L"
  102.                IF EMPTY(c_DbfDef)
  103.                   c_Default = [.F.]
  104.                 ELSE
  105.                   c_Default = c_DbfDef
  106.                ENDIF
  107.  
  108.  
  109.             CASE _DICTFLD->FIELD_TYPE = "D"
  110.                IF EMPTY(c_DbfDef)
  111.                   c_Default = [DATE()]
  112.                 ELSE
  113.                   c_Default = c_DbfDef
  114.                ENDIF
  115.  
  116.  
  117.          ENDCASE
  118.                         
  119.          VS_WriteLn( "#DEFINE  " + UPPER(PADR(c_DefName,40)) +c_Default )
  120.  
  121.          _DICTFLD->(DBSKIP())
  122.  
  123.       ENDDO
  124.       
  125.       *══════════════════════════════════════════════════════════*
  126.       
  127.  
  128.  
  129.       VS_WriteLn( "" )
  130.       VS_WriteLn( "" )
  131.  
  132.  
  133.       _DICTFLD->(DBSEEK(_DICTHDR->DBF_NAME))
  134.  
  135.       DO WHILE .NOT. _DICTFLD->(EOF())
  136.  
  137.          IF _DICTFLD->DBF_NAME <> _DICTHDR->DBF_NAME
  138.             EXIT
  139.          ENDIF
  140.  
  141.          c_PicName = "_PIC_"+ALLTRIM(_DICTFLD->DBF_NAME)  + ;
  142.                      "_"+ALLTRIM(_DICTFLD->FIELD_NAME)
  143.  
  144.          c_DbfPic  = ALLTRIM(_DICTFLD->PICTURE)
  145.  
  146.          *****
  147.          * What type of data are we working with?
  148.          *****
  149.          DO CASE
  150.  
  151.             CASE _DICTFLD->FIELD_TYPE = "C"
  152.                IF EMPTY(c_DbfPic)
  153.                   c_Picture = [REPLICATE("X",]+ALLTRIM(STR(_DICTFLD->FIELD_LEN))+")"
  154.                 ELSe
  155.                   c_Picture = c_DbfPic
  156.                ENDIF
  157.  
  158.  
  159.             CASE _DICTFLD->FIELD_TYPE = "N"
  160.                IF EMPTY(c_DbfPic)
  161.                   IF _DICTFLD->FIELD_DEC > 0
  162.                      n_Prior = (_DICTFLD->FIELD_LEN - _DICTFLD->FIELD_DEC) - 1
  163.                      c_Picture = ["]+ REPLICATE("9",n_Prior) +"."+ REPLICATE("9",_DICTFLD->FIELD_DEC) + ["]
  164.                    ELSE
  165.                      c_Picture = ["] + REPLICATE("9",_DICTFLD->FIELD_LEN) + ["]
  166.                   ENDIF
  167.                 ELSE
  168.                   c_Picture = c_DbfPic
  169.                ENDIF
  170.  
  171.  
  172.             CASE _DICTFLD->FIELD_TYPE = "L"
  173.                IF EMPTY(c_DbfPic)
  174.                   c_Picture = ["Y"]
  175.                 ELSE
  176.                   c_Picture = c_DbfPic
  177.                ENDIF
  178.  
  179.  
  180.             CASE _DICTFLD->FIELD_TYPE = "D"
  181.                IF EMPTY(c_DbfPic)
  182.                   c_Picture = ["99/99/99"]
  183.                 ELSE
  184.                   c_Picture = c_DbfPic
  185.                ENDIF
  186.  
  187.          ENDCASE
  188.  
  189.          VS_WriteLn( "#DEFINE  " + UPPER(PADR(c_PicName,40)) +c_Picture )
  190.                              
  191.          _DICTFLD->(DBSKIP())
  192.  
  193.       ENDDO
  194.  
  195.       FCLOSE(n_Handle)
  196.  
  197.       _DICTHDR->(DBSKIP())
  198.  
  199.    ENDDO
  200.  
  201.    _DICTHDR->( dbGoTop() )
  202.  
  203. VS_PutScr()
  204.  
  205. RETURN(NIL)
  206. *** EOF: GenInc() ***********************************************************
  207.  
  208.  
  209.